Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #105760

Merged
merged 26 commits into from
Dec 16, 2022
Merged

Rollup of 8 pull requests #105760

merged 26 commits into from
Dec 16, 2022

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

ouz-a and others added 26 commits December 14, 2022 14:05
This option will output some stats from the monomorphization collection
pass to a file, to show estimated sizes from each instantiation.
`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't
need the generic parameter.
When `with_forced_trimmed_paths` is used, only print filename and start
of the closure's span, to reduce their verbosity.
Do not say "Type changed to X here" when the only difference is caused
by lifetimes.
Start improving monomorphization items stats

As described in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Compile-time.20case-study.3A.20AWS.20crates/near/314560832), some stats about monomorphization collection would be interesting to have, in a different form than `-Zprint-mono-items`: to have some visibility into the cost of the mono items, we'd like to know how many are instantiated and what is their estimated size.

That can be a proxy to analyze sources of slow compile times, although in the future, we'd also like to add more realistic stats from the actual backend's lowering.

This PR adds a new `-Z dump-mono-stats` flag which will output some stats in a `{crate_name}.mono-items.md` file (the flag optionally takes an output directory parameter, for easier use within a workspace than printing to stdout).

For example,

```rust
fn compute<T>(collection: Vec<T>) -> usize {
    collection.len() + 19 - 0 * 9 - 18 - 1 * 1 // random code to increase the function's size
}

fn main() {
    dbg!(compute(vec![0u8, 1, 2]));
    dbg!(compute(vec![0u64, 1, 2]));
    dbg!(compute(vec!["0", "1", "2", "3"]));
}
```

will output a file with this markdown table (abridged for readability), for a debug build:

| Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost |
| --- | ---: | ---: | ---: |
| alloc::alloc::box_free | 3 | 122 | 366 |
| std::alloc::Global::alloc_impl | 1 | 284 | 284 |
| alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 |
| std::ptr::align_offset | 1 | 222 | 222 |
| std::slice::hack::into_vec | 3 | 67 | 201 |
| <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 |
| std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 |
| main | 1 | 163 | 163 |
| std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 |
...

<details>
<summary>Click for full output</summary>

| Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost |
| --- | ---: | ---: | ---: |
| alloc::alloc::box_free | 3 | 122 | 366 |
| std::alloc::Global::alloc_impl | 1 | 284 | 284 |
| alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 |
| std::ptr::align_offset | 1 | 222 | 222 |
| std::slice::hack::into_vec | 3 | 67 | 201 |
| <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 |
| std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 |
| main | 1 | 163 | 163 |
| std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 |
| std::boxed::Box::<T, A>::into_unique | 3 | 48 | 144 |
| std::boxed::Box::<T, A>::leak | 3 | 39 | 117 |
| std::alloc::Layout::array::inner | 1 | 107 | 107 |
| std::ptr::align_offset::mod_inv | 1 | 103 | 103 |
| std::boxed::Box::<T, A>::into_raw_with_allocator | 3 | 31 | 93 |
| std::fmt::Arguments::<'a>::new_v1 | 1 | 80 | 80 |
| <alloc::raw_vec::RawVec<T, A> as std::ops::Drop>::drop | 3 | 26 | 78 |
| alloc::raw_vec::RawVec::<T, A>::from_raw_parts_in | 3 | 26 | 78 |
| alloc::alloc::exchange_malloc | 1 | 75 | 75 |
| std::ptr::const_ptr::<impl *const T>::is_null | 1 | 75 | 75 |
| std::ptr::const_ptr::<impl *const T>::is_aligned_to | 1 | 64 | 64 |
| compute | 3 | 20 | 60 |
| std::ptr::const_ptr::<impl *const T>::align_offset | 1 | 55 | 55 |
| std::ptr::read | 1 | 52 | 52 |
| <std::alloc::Global as std::alloc::Allocator>::deallocate | 1 | 50 | 50 |
| std::ptr::mut_ptr::<impl *mut T>::guaranteed_eq | 1 | 48 | 48 |
| std::fmt::ArgumentV1::<'a>::new_display | 2 | 22 | 44 |
| std::ptr::Alignment::new_unchecked | 1 | 42 | 42 |
| core::fmt::num::<impl std::fmt::Debug for usize>::fmt | 1 | 40 | 40 |
| std::result::Result::<T, E>::unwrap_unchecked | 1 | 37 | 37 |
| std::cmp::Ord::min | 1 | 32 | 32 |
| std::cmp::impls::<impl std::cmp::Ord for usize>::cmp | 1 | 31 | 31 |
| std::intrinsics::is_aligned_and_not_null | 1 | 27 | 27 |
| std::rt::lang_start | 1 | 27 | 27 |
| std::ptr::NonNull::<T>::new | 1 | 24 | 24 |
| std::fmt::ArgumentV1::<'a>::new_debug | 1 | 22 | 22 |
| std::fmt::Arguments::<'a>::new_v1_formatted | 1 | 19 | 19 |
| std::rt::lang_start::{closure#0} | 1 | 17 | 17 |
| std::sys_common::backtrace::__rust_begin_short_backtrace | 1 | 16 | 16 |
| std::slice::<impl [T]>::into_vec | 3 | 5 | 15 |
| <std::ptr::NonNull<T> as std::convert::From<std::ptr::Unique<T>>>::from | 1 | 14 | 14 |
| <&T as std::fmt::Debug>::fmt | 1 | 12 | 12 |
| <&T as std::fmt::Display>::fmt | 1 | 12 | 12 |
| std::vec::Vec::<T, A>::len | 3 | 2 | 6 |
| <T as std::convert::Into<U>>::into | 1 | 5 | 5 |
| <T as std::convert::From<T>>::from | 1 | 2 | 2 |
| <() as std::process::Termination>::report | 1 | 2 | 2 |
| std::hint::unreachable_unchecked | 1 | 2 | 2 |
| core::fmt::UnsafeArg::new | 1 | 1 | 1 |

</details>

Since we discussed it together, r? `@wesleywiser.`
Point at method chains on `E0271` errors

Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082.

r? `@oli-obk`
…-errors

Suggest constraining type parameter with `Clone`

Fix rust-lang#34896.
Don't create dummy if val has escaping bounds var

Skips creating/pushing obligations if val has escaping bounds vars.

Fixes rust-lang#105689
Tweak output for bare `dyn Trait` in arguments

Fix rust-lang#35825.
…-link-to-css-var, r=notriddle

Migrate Jump to def links background to CSS variable

It's already tested in `src/test/rustdoc-gui/jump-to-def-background.goml`.

r? `@notriddle`
…s, r=lcnr

`SimplifiedType` cleanups

r? `@lcnr`
…mpiler-errors

Move `TypeckResults` to separate module

`ty::context` is really big and the typeck results aren't directly related to `TyCtxt`, so move them to a separate module. Also contains a small drive-by macro "improvement".
@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 15, 2022
@rustbot rustbot added the rollup A PR which is a rollup label Dec 15, 2022
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Contributor

bors commented Dec 15, 2022

📌 Commit 2e03ff1 has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 15, 2022
@bors
Copy link
Contributor

bors commented Dec 15, 2022

⌛ Testing commit 2e03ff1 with merge 7a6af27...

@bors
Copy link
Contributor

bors commented Dec 16, 2022

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing 7a6af27 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 16, 2022
@bors bors merged commit 7a6af27 into rust-lang:master Dec 16, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 16, 2022
@rust-timer
Copy link
Collaborator

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7a6af27): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.0% [4.0%, 4.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 3
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

@matthiaskrgr matthiaskrgr deleted the rollup-r8beo9w branch December 22, 2022 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants